package com.moshme.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moshme.project.domain.ProjectStepUser;
import com.moshme.project.mapper.ProjectStepUserMapper;
import com.moshme.project.service.ProjectStepUserService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 望夜
 * @date 2023/8/23---9:19
 * @SuppressWarnings({"all"})
 */
@Service
public class ProjectStepUserServiceImpl extends ServiceImpl<ProjectStepUserMapper, ProjectStepUser> implements ProjectStepUserService {
    @Override
    public Long[] getAllUserIdsByStepId(Long stepId) {
        LambdaQueryWrapper<ProjectStepUser> wrapper = new LambdaQueryWrapper<ProjectStepUser>().eq(ProjectStepUser::getStepId,stepId);
        List<ProjectStepUser> dockStepUsers = baseMapper.selectList(wrapper);
        ArrayList<Long> list = new ArrayList<>();
        for (ProjectStepUser dockStepUser : dockStepUsers) {
            list.add(dockStepUser.getUserId());
        }

        Long[] userIds = list.toArray(new Long[0]);
        return userIds;
    }


    //删除关联
    @Override
    public void deleteProjectStepUser(Long stepId) {
        baseMapper.deleteById(stepId);
    }
}
